/***********************************************************
File name     : xstddef.h
Author name   : lancz
Email address : chengzhang.lan@jointlighting.com
Create time   : 2022-09-07 16:23:32
***********************************************************/
#ifndef __STDDEF_H__
#define __STDDEF_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>
#include <stdbool.h>

typedef enum {
    XFALSE = 0,
    XTRUE = !XFALSE
} xt_bool;

typedef char xt_s8;
typedef unsigned char xt_u8;
typedef signed short xt_s16;
typedef unsigned short xt_u16;
typedef signed int xt_s32;
typedef unsigned int xt_u32;
typedef signed long xt_slong;
typedef unsigned long xt_ulong;
typedef long long xt_s64;
typedef unsigned long long xt_u64;
typedef char *xt_string;
typedef const char *xt_rostring;
typedef void xt_void;
typedef float xt_float;
typedef double xt_double;

typedef enum {
    XERROR_EMPTY = -6,
    XERROR_TIMEOUT = -5,
    XERROR_MEM = -4,
    XERROR_EXIST = -3,
    XERROR_FUNC_ARGS = -2,
    XERROR = -1,
    XOK = 0
} xt_result;

#if defined(__ICCARM__)
#define STR(s) #s
#define SECTION(_name) _Pragma(STRINGIFY(location = _name))
#define ALIGNMTO(_bound) _Pragma(STRINGIFY(data_alignment = ##_bound##))
#define PACKED_ __packed
#define LONG_CALL_
#define LONG_CALL_ROM_
#define WEAK __weak
#else
#define SECTION(_name) __attribute__((__section__(_name)))
#define ALIGNMTO(_bound) __attribute__((aligned(_bound)))
#define PACKED_ __attribute__((packed))
#define LONG_CALL_ __attribute__((long_call))
#define WEAK __attribute__((weak))
#endif

#define XBIT_IS_SET(data, bit) (((data) & (1 << (bit))) != 0)

#ifdef __cplusplus
}
#endif

#endif
